@aaamb/ngx-design-system 1.4.1 → 1.4.2
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/fesm2022/aaamb-ngx-design-system.mjs +4118 -0
- package/fesm2022/aaamb-ngx-design-system.mjs.map +1 -0
- package/package.json +14 -58
- package/styles/compiled.css +2 -0
- package/types/aaamb-ngx-design-system.d.ts +1149 -0
- package/.editorconfig +0 -17
- package/.nvmrc +0 -1
- package/.postcssrc.json +0 -5
- package/.storybook/main.ts +0 -20
- package/.storybook/preview.ts +0 -23
- package/.storybook/storybook.css +0 -1
- package/.storybook/tsconfig.json +0 -19
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/tasks.json +0 -42
- package/CHANGELOG.md +0 -10
- package/LOCAL_DEVELOPMENT.md +0 -129
- package/angular.json +0 -74
- package/bitbucket-pipelines.yml +0 -41
- package/iac/bin/app.ts +0 -42
- package/iac/cdk.json +0 -82
- package/iac/lib/config/environments.ts +0 -19
- package/iac/lib/config/types.ts +0 -13
- package/iac/lib/stacks/certificate-stack.ts +0 -34
- package/iac/lib/stacks/frontend-stack.ts +0 -120
- package/iac/lib/stacks/index.ts +0 -2
- package/iac/package-lock.json +0 -726
- package/iac/package.json +0 -25
- package/iac/tsconfig.json +0 -24
- package/ng-package.json +0 -8
- package/src/components/button/button-green.stories.ts +0 -101
- package/src/components/button/button-text.stories.ts +0 -105
- package/src/components/button/button-white.stories.ts +0 -105
- package/src/components/button/button.component.stories.ts +0 -91
- package/src/components/button/button.component.ts +0 -93
- package/src/components/checkbox/checkbox.component.html +0 -30
- package/src/components/checkbox/checkbox.component.stories.ts +0 -183
- package/src/components/checkbox/checkbox.component.ts +0 -211
- package/src/components/datepicker-selector/datepicker-selector.component.html +0 -103
- package/src/components/datepicker-selector/datepicker-selector.component.stories.ts +0 -123
- package/src/components/datepicker-selector/datepicker-selector.component.ts +0 -337
- package/src/components/error-message/error-message.component.html +0 -3
- package/src/components/error-message/error-message.component.ts +0 -13
- package/src/components/filter-button/filter-button.component.html +0 -286
- package/src/components/filter-button/filter-button.component.stories.ts +0 -123
- package/src/components/filter-button/filter-button.component.ts +0 -582
- package/src/components/icon/icon.component.ts +0 -20
- package/src/components/icon/icon.html +0 -1424
- package/src/components/icon/icon.stories.ts +0 -49
- package/src/components/icon/icons-list.stories.ts +0 -42
- package/src/components/input/input.component.stories.ts +0 -101
- package/src/components/input/input.component.ts +0 -317
- package/src/components/input/input.html +0 -160
- package/src/components/input-datepicker/input-datepicker.component.ts +0 -356
- package/src/components/input-datepicker/input-datepicker.html +0 -69
- package/src/components/input-datepicker/input-datepicker.stories.ts +0 -99
- package/src/components/input-rangepicker/input-rangepicker.component.ts +0 -365
- package/src/components/input-rangepicker/input-rangepicker.html +0 -54
- package/src/components/input-rangepicker/input-rangepicker.stories.ts +0 -88
- package/src/components/input-weekpicker/input-weekpicker.component.ts +0 -417
- package/src/components/input-weekpicker/input-weekpicker.html +0 -54
- package/src/components/input-weekpicker/input-weekpicker.stories.ts +0 -103
- package/src/components/label/label.component.html +0 -20
- package/src/components/label/label.component.ts +0 -22
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.html +0 -32
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.stories.ts +0 -57
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.ts +0 -48
- package/src/components/modals/feedback-modal/feedback-modal.component.html +0 -118
- package/src/components/modals/feedback-modal/feedback-modal.component.stories.ts +0 -93
- package/src/components/modals/feedback-modal/feedback-modal.component.ts +0 -187
- package/src/components/modals/help-modal/help-modal.component.html +0 -32
- package/src/components/modals/help-modal/help-modal.component.stories.ts +0 -76
- package/src/components/modals/help-modal/help-modal.component.ts +0 -54
- package/src/components/modals/information-modal/information-modal.component.html +0 -24
- package/src/components/modals/information-modal/information-modal.component.stories.ts +0 -62
- package/src/components/modals/information-modal/information-modal.component.ts +0 -35
- package/src/components/modals/main-modal/main-modal.component.html +0 -85
- package/src/components/modals/main-modal/main-modal.component.stories.ts +0 -127
- package/src/components/modals/main-modal/main-modal.component.ts +0 -85
- package/src/components/modals/notification-modal/notification-modal.component.html +0 -22
- package/src/components/modals/notification-modal/notification-modal.component.stories.ts +0 -59
- package/src/components/modals/notification-modal/notification-modal.component.ts +0 -37
- package/src/components/selectors/multiple-selector/multiple-selector.component.html +0 -51
- package/src/components/selectors/multiple-selector/multiple-selector.component.stories.ts +0 -306
- package/src/components/selectors/multiple-selector/multiple-selector.component.ts +0 -308
- package/src/components/selectors/single-selector/single-selector.component.html +0 -46
- package/src/components/selectors/single-selector/single-selector.component.stories.ts +0 -294
- package/src/components/selectors/single-selector/single-selector.component.ts +0 -239
- package/src/components/side-nav/side-nav.component.stories.ts +0 -176
- package/src/components/side-nav/side-nav.component.ts +0 -325
- package/src/components/snackbar/snackbar.component.ts +0 -150
- package/src/components/snackbar/snackbar.html +0 -21
- package/src/components/snackbar/snackbar.stories.ts +0 -51
- package/src/components/state/state.component.ts +0 -30
- package/src/components/state/state.html +0 -13
- package/src/components/state/state.stories.ts +0 -74
- package/src/components/table/table.component.html +0 -466
- package/src/components/table/table.component.scss +0 -28
- package/src/components/table/table.component.stories.ts +0 -655
- package/src/components/table/table.component.ts +0 -475
- package/src/components/tabs/tabs.component.stories.ts +0 -114
- package/src/components/tabs/tabs.component.ts +0 -69
- package/src/core/types.ts +0 -494
- package/src/public-api.ts +0 -23
- package/tsconfig.json +0 -37
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -13
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
-
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
-
import { CheckboxComponent } from './checkbox.component';
|
|
4
|
-
|
|
5
|
-
type CheckboxProps = CheckboxComponent & { checked: boolean };
|
|
6
|
-
|
|
7
|
-
const meta: Meta<CheckboxProps> = {
|
|
8
|
-
title: 'Components/Checkbox',
|
|
9
|
-
component: CheckboxComponent,
|
|
10
|
-
args: {
|
|
11
|
-
appearance: 'square',
|
|
12
|
-
label: 'Checkbox',
|
|
13
|
-
labelPosition: 'right',
|
|
14
|
-
labelColor: 'green',
|
|
15
|
-
checked: false,
|
|
16
|
-
disabled: false,
|
|
17
|
-
},
|
|
18
|
-
argTypes: {
|
|
19
|
-
appearance: { control: 'select', options: ['square', 'toggle', 'radio'] },
|
|
20
|
-
label: { control: 'text' },
|
|
21
|
-
labelPosition: { control: 'select', options: ['left', 'right'] },
|
|
22
|
-
labelColor: { control: 'select', options: ['green', 'white'] },
|
|
23
|
-
checked: { control: 'boolean' },
|
|
24
|
-
disabled: { control: 'boolean' },
|
|
25
|
-
},
|
|
26
|
-
render: (args) => ({
|
|
27
|
-
props: args,
|
|
28
|
-
template: `
|
|
29
|
-
<div class="p-6" [class.bg-green-base]="labelColor === 'white'">
|
|
30
|
-
<ads-checkbox
|
|
31
|
-
[appearance]="appearance"
|
|
32
|
-
[label]="label"
|
|
33
|
-
[labelPosition]="labelPosition"
|
|
34
|
-
[labelColor]="labelColor"
|
|
35
|
-
[checked]="checked"
|
|
36
|
-
[disabled]="disabled"
|
|
37
|
-
(checkedChange)="checked = $event"
|
|
38
|
-
></ads-checkbox>
|
|
39
|
-
</div>
|
|
40
|
-
`,
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default meta;
|
|
45
|
-
type Story = StoryObj<CheckboxProps>;
|
|
46
|
-
|
|
47
|
-
export const Playground: Story = {};
|
|
48
|
-
|
|
49
|
-
export const ReactiveForms: Story = {
|
|
50
|
-
args: {
|
|
51
|
-
appearance: 'toggle',
|
|
52
|
-
label: 'Reactive checkbox',
|
|
53
|
-
labelPosition: 'right',
|
|
54
|
-
labelColor: 'green',
|
|
55
|
-
disabled: false,
|
|
56
|
-
},
|
|
57
|
-
render: (args) => {
|
|
58
|
-
const form = new FormGroup({
|
|
59
|
-
selection: new FormControl(false, { nonNullable: true }),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
moduleMetadata: {
|
|
64
|
-
imports: [ReactiveFormsModule],
|
|
65
|
-
},
|
|
66
|
-
props: {
|
|
67
|
-
...args,
|
|
68
|
-
form,
|
|
69
|
-
},
|
|
70
|
-
template: `
|
|
71
|
-
<div class="p-6 space-y-4">
|
|
72
|
-
<form [formGroup]="form">
|
|
73
|
-
<ads-checkbox
|
|
74
|
-
formControlName="selection"
|
|
75
|
-
[appearance]="appearance"
|
|
76
|
-
[label]="label"
|
|
77
|
-
[labelPosition]="labelPosition"
|
|
78
|
-
[labelColor]="labelColor"
|
|
79
|
-
[disabled]="disabled"
|
|
80
|
-
></ads-checkbox>
|
|
81
|
-
</form>
|
|
82
|
-
|
|
83
|
-
<p class="text-sm text-green-base m-0">Value: {{ form.get('selection')?.value }}</p>
|
|
84
|
-
</div>
|
|
85
|
-
`,
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const ReactiveFormsRadioGroup: Story = {
|
|
91
|
-
args: {
|
|
92
|
-
appearance: 'radio',
|
|
93
|
-
labelPosition: 'right',
|
|
94
|
-
labelColor: 'green',
|
|
95
|
-
disabled: false,
|
|
96
|
-
},
|
|
97
|
-
render: (args) => {
|
|
98
|
-
const form = new FormGroup({
|
|
99
|
-
channel: new FormControl<'email' | 'sms'>('email', { nonNullable: true }),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
moduleMetadata: {
|
|
104
|
-
imports: [ReactiveFormsModule],
|
|
105
|
-
},
|
|
106
|
-
props: {
|
|
107
|
-
...args,
|
|
108
|
-
form,
|
|
109
|
-
setChannel: (channel: 'email' | 'sms', checked: boolean) => {
|
|
110
|
-
if (checked) {
|
|
111
|
-
form.controls.channel.setValue(channel);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
template: `
|
|
116
|
-
<div class="p-6 space-y-4">
|
|
117
|
-
<p class="text-sm text-green-base mb-2">Selecciona un canal</p>
|
|
118
|
-
|
|
119
|
-
<div class="flex gap-3 m-0">
|
|
120
|
-
<ads-checkbox
|
|
121
|
-
appearance="radio"
|
|
122
|
-
label="Email"
|
|
123
|
-
[labelPosition]="labelPosition"
|
|
124
|
-
[labelColor]="labelColor"
|
|
125
|
-
[disabled]="disabled"
|
|
126
|
-
[checked]="form.controls.channel.value === 'email'"
|
|
127
|
-
(checkedChange)="setChannel('email', $event)"
|
|
128
|
-
></ads-checkbox>
|
|
129
|
-
|
|
130
|
-
<ads-checkbox
|
|
131
|
-
appearance="radio"
|
|
132
|
-
label="SMS"
|
|
133
|
-
[labelPosition]="labelPosition"
|
|
134
|
-
[labelColor]="labelColor"
|
|
135
|
-
[disabled]="disabled"
|
|
136
|
-
[checked]="form.controls.channel.value === 'sms'"
|
|
137
|
-
(checkedChange)="setChannel('sms', $event)"
|
|
138
|
-
></ads-checkbox>
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
<p class="text-sm text-green-base m-0">Value: {{ form.controls.channel.value }}</p>
|
|
142
|
-
</div>
|
|
143
|
-
`,
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export const StatesReference: Story = {
|
|
149
|
-
render: () => ({
|
|
150
|
-
template: `
|
|
151
|
-
<div class="bg-[#c5c5c5] p-10">
|
|
152
|
-
<div class="grid grid-cols-3 items-start gap-x-16 gap-y-10">
|
|
153
|
-
<div class="space-y-4">
|
|
154
|
-
<h3 class="m-0 text-white-base text-xl font-medium leading-none">Square</h3>
|
|
155
|
-
<div class="h-4"></div>
|
|
156
|
-
<ads-checkbox class="block" appearance="square" label="Default/ Unselected" labelColor="white"></ads-checkbox>
|
|
157
|
-
<ads-checkbox class="block" appearance="square" label="Default/ Pressed" labelColor="white" [checked]="true"></ads-checkbox>
|
|
158
|
-
<ads-checkbox class="block" appearance="square" label="Disabled/ Unselected" labelColor="white" [disabled]="true"></ads-checkbox>
|
|
159
|
-
<ads-checkbox class="block" appearance="square" label="Disabled/ Pressed" labelColor="white" [disabled]="true" [checked]="true"></ads-checkbox>
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<div class="space-y-4">
|
|
163
|
-
<h3 class="m-0 text-white-base text-xl font-medium leading-none">Toggle</h3>
|
|
164
|
-
<div class="h-4"></div>
|
|
165
|
-
<ads-checkbox class="block" appearance="toggle" labelColor="white"></ads-checkbox>
|
|
166
|
-
<ads-checkbox class="block" appearance="toggle" labelColor="white" [checked]="true"></ads-checkbox>
|
|
167
|
-
<ads-checkbox class="block" appearance="toggle" labelColor="white" [disabled]="true"></ads-checkbox>
|
|
168
|
-
<ads-checkbox class="block" appearance="toggle" labelColor="white" [checked]="true" [disabled]="true"></ads-checkbox>
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
<div class="space-y-4">
|
|
172
|
-
<h3 class="m-0 text-white-base text-xl font-medium leading-none">Radio</h3>
|
|
173
|
-
<div class="h-4"></div>
|
|
174
|
-
<ads-checkbox class="block" appearance="radio" label="Default/ Unselected" labelColor="white"></ads-checkbox>
|
|
175
|
-
<ads-checkbox class="block" appearance="radio" label="Default/ Pressed" labelColor="white" [checked]="true"></ads-checkbox>
|
|
176
|
-
<ads-checkbox class="block" appearance="radio" label="Disabled/ Unselected" labelColor="white" [disabled]="true"></ads-checkbox>
|
|
177
|
-
<ads-checkbox class="block" appearance="radio" label="Disabled/ Pressed" labelColor="white" [checked]="true" [disabled]="true"></ads-checkbox>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
`,
|
|
182
|
-
}),
|
|
183
|
-
};
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
effect,
|
|
4
|
-
forwardRef,
|
|
5
|
-
input,
|
|
6
|
-
output,
|
|
7
|
-
signal,
|
|
8
|
-
} from '@angular/core';
|
|
9
|
-
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
|
-
import {
|
|
11
|
-
AdsCheckboxAppearance,
|
|
12
|
-
AdsCheckboxLabelColor,
|
|
13
|
-
AdsCheckboxLabelPosition,
|
|
14
|
-
} from '../../core/types';
|
|
15
|
-
import { IconComponent } from '../icon/icon.component';
|
|
16
|
-
|
|
17
|
-
@Component({
|
|
18
|
-
selector: 'ads-checkbox',
|
|
19
|
-
standalone: true,
|
|
20
|
-
imports: [IconComponent],
|
|
21
|
-
templateUrl: './checkbox.component.html',
|
|
22
|
-
host: {
|
|
23
|
-
class: 'inline-block align-middle',
|
|
24
|
-
},
|
|
25
|
-
providers: [
|
|
26
|
-
{
|
|
27
|
-
provide: NG_VALUE_ACCESSOR,
|
|
28
|
-
useExisting: forwardRef(() => CheckboxComponent),
|
|
29
|
-
multi: true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
})
|
|
33
|
-
export class CheckboxComponent implements ControlValueAccessor {
|
|
34
|
-
appearance = input<AdsCheckboxAppearance>('square');
|
|
35
|
-
label = input<string>('');
|
|
36
|
-
labelPosition = input<AdsCheckboxLabelPosition>('right');
|
|
37
|
-
labelColor = input<AdsCheckboxLabelColor>('green');
|
|
38
|
-
checked = input<boolean>(false);
|
|
39
|
-
disabled = input<boolean>(false);
|
|
40
|
-
|
|
41
|
-
checkedChange = output<boolean>();
|
|
42
|
-
|
|
43
|
-
private cvaMode = false;
|
|
44
|
-
private cvaDisabled = false;
|
|
45
|
-
currentChecked = signal<boolean>(false);
|
|
46
|
-
|
|
47
|
-
private onChange: (value: boolean) => void = () => {};
|
|
48
|
-
private onTouched: () => void = () => {};
|
|
49
|
-
|
|
50
|
-
constructor() {
|
|
51
|
-
effect(() => {
|
|
52
|
-
if (!this.cvaMode) {
|
|
53
|
-
this.currentChecked.set(this.checked());
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
isDisabled(): boolean {
|
|
59
|
-
return this.disabled() || this.cvaDisabled;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
wrapperClasses(): string {
|
|
63
|
-
return 'flex items-center gap-2 select-none';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
labelClasses(): string {
|
|
67
|
-
const base = 'text-base leading-6';
|
|
68
|
-
|
|
69
|
-
if (this.isDisabled()) {
|
|
70
|
-
return `${base} text-[#01474480]`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (this.labelColor() === 'white') {
|
|
74
|
-
return `${base} text-white-base`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return `${base} text-green-base`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
controlClasses(): string {
|
|
81
|
-
const base =
|
|
82
|
-
'inline-flex shrink-0 items-center justify-center border border-solid cursor-pointer transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-aqua-2 disabled:pointer-events-none disabled:cursor-not-allowed';
|
|
83
|
-
|
|
84
|
-
if (this.appearance() === 'toggle') {
|
|
85
|
-
const toggleBase = `${base} relative justify-start h-7 w-13 rounded-full p-0.5`;
|
|
86
|
-
|
|
87
|
-
if (this.isDisabled()) {
|
|
88
|
-
if (this.currentChecked()) {
|
|
89
|
-
return `${toggleBase} border-[#01474480] bg-aqua-6`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return `${toggleBase} border-[#01474480] bg-transparent`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (this.currentChecked()) {
|
|
96
|
-
return `${toggleBase} border-green-base bg-aqua-5`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return `${toggleBase} border-green-base bg-transparent`;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (this.appearance() === 'radio') {
|
|
103
|
-
const radioBase = `${base} h-6 w-6 rounded-full`;
|
|
104
|
-
|
|
105
|
-
if (this.isDisabled()) {
|
|
106
|
-
if (this.currentChecked()) {
|
|
107
|
-
return `${radioBase} border-[#80A3A2] bg-[#80A3A2]`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return `${radioBase} border-[#01474480] bg-transparent`;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (this.currentChecked()) {
|
|
114
|
-
return `${radioBase} border-green-base bg-green-base`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return `${radioBase} border-green-base bg-transparent`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const squareBase = `${base} h-6 w-6 rounded-[5px] p-1`;
|
|
121
|
-
|
|
122
|
-
if (this.isDisabled()) {
|
|
123
|
-
if (this.currentChecked()) {
|
|
124
|
-
return `${squareBase} border-[#80A3A2] bg-[#80A3A2] text-white-base`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return `${squareBase} border-[#01474480] bg-transparent`;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (this.currentChecked()) {
|
|
131
|
-
return `${squareBase} border-green-base bg-green-base text-white-base`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return `${squareBase} border-green-base bg-transparent`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
toggleThumbClasses(): string {
|
|
138
|
-
const base = 'h-5 w-5 rounded-full transition-transform duration-150';
|
|
139
|
-
|
|
140
|
-
if (this.currentChecked()) {
|
|
141
|
-
const checkedColor = this.isDisabled()
|
|
142
|
-
? 'bg-[#01474480]'
|
|
143
|
-
: 'bg-green-base';
|
|
144
|
-
return `${base} translate-x-6.5 ${checkedColor}`;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const uncheckedColor = this.isDisabled()
|
|
148
|
-
? 'bg-neutral-disabled-bg'
|
|
149
|
-
: 'bg-aqua-5';
|
|
150
|
-
|
|
151
|
-
return `${base} translate-x-0 ${uncheckedColor}`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
radioDotClasses(): string {
|
|
155
|
-
const base = 'h-2 w-2 rounded-full';
|
|
156
|
-
|
|
157
|
-
if (this.isDisabled()) {
|
|
158
|
-
return `${base} bg-white-base`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return `${base} bg-white-base`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
controlRole(): 'checkbox' | 'switch' | 'radio' {
|
|
165
|
-
if (this.appearance() === 'toggle') {
|
|
166
|
-
return 'switch';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (this.appearance() === 'radio') {
|
|
170
|
-
return 'radio';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return 'checkbox';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
onControlClick(): void {
|
|
177
|
-
if (this.isDisabled()) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const nextChecked =
|
|
182
|
-
this.appearance() === 'radio' ? true : !this.currentChecked();
|
|
183
|
-
|
|
184
|
-
if (nextChecked === this.currentChecked()) {
|
|
185
|
-
this.onTouched();
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
this.currentChecked.set(nextChecked);
|
|
190
|
-
this.onChange(nextChecked);
|
|
191
|
-
this.checkedChange.emit(nextChecked);
|
|
192
|
-
this.onTouched();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
writeValue(value: unknown): void {
|
|
196
|
-
this.cvaMode = true;
|
|
197
|
-
this.currentChecked.set(Boolean(value));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
registerOnChange(fn: (value: boolean) => void): void {
|
|
201
|
-
this.onChange = fn;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
registerOnTouched(fn: () => void): void {
|
|
205
|
-
this.onTouched = fn;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
setDisabledState(isDisabled: boolean): void {
|
|
209
|
-
this.cvaDisabled = isDisabled;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<div class="relative inline-flex flex-col gap-3 w-full max-w-90">
|
|
2
|
-
<div class="flex items-center justify-between gap-3">
|
|
3
|
-
<button
|
|
4
|
-
#selectorTrigger
|
|
5
|
-
ads-button=""
|
|
6
|
-
type="button"
|
|
7
|
-
[variant]="buttonVariant()"
|
|
8
|
-
[color]="buttonColor()"
|
|
9
|
-
[onlyIconButton]="buttonOnlyIconButton()"
|
|
10
|
-
[iconButton]="buttonIcon()"
|
|
11
|
-
[disabled]="isDisabled()"
|
|
12
|
-
(click)="toggleSelector()"
|
|
13
|
-
[attr.aria-expanded]="isSelectorOpen()"
|
|
14
|
-
aria-haspopup="menu"
|
|
15
|
-
>
|
|
16
|
-
<ads-icon [iconName]="buttonIcon()" [size]="16"></ads-icon>
|
|
17
|
-
@if (!buttonOnlyIconButton()) {
|
|
18
|
-
<span>{{ buttonLabel() }}</span>
|
|
19
|
-
}
|
|
20
|
-
</button>
|
|
21
|
-
|
|
22
|
-
@if (isSelectorOpen()) {
|
|
23
|
-
<div
|
|
24
|
-
class="absolute top-[calc(100%+0.5rem)] z-20 flex items-start gap-3"
|
|
25
|
-
[class.left-0]="!openToLeft()"
|
|
26
|
-
[class.right-0]="openToLeft()"
|
|
27
|
-
[class.flex-row]="!openToLeft()"
|
|
28
|
-
[class.flex-row-reverse]="openToLeft()"
|
|
29
|
-
role="menu"
|
|
30
|
-
(mouseleave)="clearPreview()"
|
|
31
|
-
>
|
|
32
|
-
<div class="w-60 overflow-hidden rounded-lg shadow-lg">
|
|
33
|
-
@for (option of pickerOptions; track option.mode) {
|
|
34
|
-
<div
|
|
35
|
-
type="button"
|
|
36
|
-
class="flex w-full items-center justify-between border-b border-b-neutral-disabled-bg bg-white px-4 py-3 text-left text-sm text-green-base transition-colors last:border-b-0 hover:bg-aqua-6 cursor-pointer"
|
|
37
|
-
(mouseenter)="previewTimeFrame(option.mode)"
|
|
38
|
-
role="menuitem"
|
|
39
|
-
>
|
|
40
|
-
<span>{{ option.label }}</span>
|
|
41
|
-
</div>
|
|
42
|
-
}
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
@if (activePreviewTimeFrame()) {
|
|
46
|
-
@switch (activePreviewTimeFrame()) {
|
|
47
|
-
@case (dateOptions.annually) {
|
|
48
|
-
<nz-date-picker
|
|
49
|
-
nzDropdownClassName="datePicker-box"
|
|
50
|
-
nzInline
|
|
51
|
-
nzMode="year"
|
|
52
|
-
[(ngModel)]="date"
|
|
53
|
-
(ngModelChange)="onDateChange(dateOptions.annually, $event)"
|
|
54
|
-
[nzDisabled]="isDisabled()"
|
|
55
|
-
[nzDisabledDate]="disableFutureDates"
|
|
56
|
-
></nz-date-picker>
|
|
57
|
-
}
|
|
58
|
-
@case (dateOptions.monthly) {
|
|
59
|
-
<nz-date-picker
|
|
60
|
-
nzInline
|
|
61
|
-
nzMode="month"
|
|
62
|
-
[(ngModel)]="date"
|
|
63
|
-
(ngModelChange)="onDateChange(dateOptions.monthly, $event)"
|
|
64
|
-
[nzDisabled]="isDisabled()"
|
|
65
|
-
[nzDisabledDate]="disableFutureDates"
|
|
66
|
-
></nz-date-picker>
|
|
67
|
-
}
|
|
68
|
-
@case (dateOptions.weekly) {
|
|
69
|
-
<nz-date-picker
|
|
70
|
-
nzInline
|
|
71
|
-
nzMode="week"
|
|
72
|
-
[(ngModel)]="date"
|
|
73
|
-
(ngModelChange)="onDateChange(dateOptions.weekly, $event)"
|
|
74
|
-
[nzDisabled]="isDisabled()"
|
|
75
|
-
[nzDisabledDate]="disableFutureDates"
|
|
76
|
-
></nz-date-picker>
|
|
77
|
-
}
|
|
78
|
-
@case (dateOptions.quarterly) {
|
|
79
|
-
<nz-date-picker
|
|
80
|
-
nzInline
|
|
81
|
-
nzMode="quarter"
|
|
82
|
-
[(ngModel)]="date"
|
|
83
|
-
(ngModelChange)="onDateChange(dateOptions.quarterly, $event)"
|
|
84
|
-
[nzDisabled]="isDisabled()"
|
|
85
|
-
[nzDisabledDate]="disableFutureDates"
|
|
86
|
-
></nz-date-picker>
|
|
87
|
-
}
|
|
88
|
-
@case (dateOptions.daily) {
|
|
89
|
-
<nz-date-picker
|
|
90
|
-
nzInline
|
|
91
|
-
[nzShowToday]="false"
|
|
92
|
-
[(ngModel)]="date"
|
|
93
|
-
(ngModelChange)="onDateChange(dateOptions.daily, $event)"
|
|
94
|
-
[nzDisabled]="isDisabled()"
|
|
95
|
-
[nzDisabledDate]="disableFutureDates"
|
|
96
|
-
></nz-date-picker>
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
</div>
|
|
101
|
-
}
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
-
import { ReactiveFormsModule, FormControl, FormGroup } from '@angular/forms';
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
4
|
-
import { DatepickerSelectorComponent } from './datepicker-selector.component';
|
|
5
|
-
import { ICONS } from '../../core/types';
|
|
6
|
-
|
|
7
|
-
const meta: Meta<DatepickerSelectorComponent> = {
|
|
8
|
-
title: 'Components/DatepickerSelector',
|
|
9
|
-
component: DatepickerSelectorComponent,
|
|
10
|
-
argTypes: {
|
|
11
|
-
buttonVariant: {
|
|
12
|
-
control: 'select',
|
|
13
|
-
options: ['primary', 'secondary'],
|
|
14
|
-
},
|
|
15
|
-
buttonColor: {
|
|
16
|
-
control: 'select',
|
|
17
|
-
options: ['green', 'white', 'text'],
|
|
18
|
-
},
|
|
19
|
-
buttonOnlyIconButton: {
|
|
20
|
-
control: 'boolean',
|
|
21
|
-
},
|
|
22
|
-
buttonIcon: {
|
|
23
|
-
control: 'select',
|
|
24
|
-
options: [...Object.keys(ICONS)],
|
|
25
|
-
},
|
|
26
|
-
buttonLabelMode: {
|
|
27
|
-
control: 'select',
|
|
28
|
-
options: ['option', 'selection'],
|
|
29
|
-
},
|
|
30
|
-
isPickerDisabled: {
|
|
31
|
-
control: 'boolean',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
render: (args) => ({
|
|
35
|
-
moduleMetadata: {
|
|
36
|
-
imports: [CommonModule, ReactiveFormsModule],
|
|
37
|
-
},
|
|
38
|
-
props: {
|
|
39
|
-
...args,
|
|
40
|
-
form: new FormGroup({
|
|
41
|
-
date: new FormControl<Date | null>(null),
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
template: `
|
|
45
|
-
<div class="p-6 gap-4 flex items-center">
|
|
46
|
-
<form [formGroup]="form">
|
|
47
|
-
<ads-datepicker-selector
|
|
48
|
-
formControlName="date"
|
|
49
|
-
[buttonVariant]="buttonVariant"
|
|
50
|
-
[buttonColor]="buttonColor"
|
|
51
|
-
[buttonOnlyIconButton]="buttonOnlyIconButton"
|
|
52
|
-
[buttonIcon]="buttonIcon"
|
|
53
|
-
[buttonLabelMode]="buttonLabelMode"
|
|
54
|
-
[isPickerDisabled]="isPickerDisabled"
|
|
55
|
-
></ads-datepicker-selector>
|
|
56
|
-
</form>
|
|
57
|
-
<span class="text-sm text-green-base">Value: {{ form.controls.date.value | date: 'MM/dd/yyyy' }}</span>
|
|
58
|
-
</div>
|
|
59
|
-
`,
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default meta;
|
|
64
|
-
type Story = StoryObj<DatepickerSelectorComponent>;
|
|
65
|
-
|
|
66
|
-
export const Playground: Story = {
|
|
67
|
-
args: {
|
|
68
|
-
buttonVariant: 'secondary',
|
|
69
|
-
buttonColor: 'white',
|
|
70
|
-
buttonOnlyIconButton: false,
|
|
71
|
-
buttonIcon: 'menu_list',
|
|
72
|
-
buttonLabelMode: 'option',
|
|
73
|
-
isPickerDisabled: false,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const SelectedValueLabel: Story = {
|
|
78
|
-
args: {
|
|
79
|
-
buttonVariant: 'secondary',
|
|
80
|
-
buttonColor: 'white',
|
|
81
|
-
buttonOnlyIconButton: false,
|
|
82
|
-
buttonIcon: 'menu_list',
|
|
83
|
-
buttonLabelMode: 'selection',
|
|
84
|
-
isPickerDisabled: false,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const AlignedToRight: Story = {
|
|
89
|
-
args: {
|
|
90
|
-
buttonVariant: 'secondary',
|
|
91
|
-
buttonColor: 'white',
|
|
92
|
-
buttonOnlyIconButton: false,
|
|
93
|
-
buttonIcon: 'menu_list',
|
|
94
|
-
buttonLabelMode: 'selection',
|
|
95
|
-
isPickerDisabled: false,
|
|
96
|
-
},
|
|
97
|
-
render: (args) => ({
|
|
98
|
-
moduleMetadata: {
|
|
99
|
-
imports: [CommonModule, ReactiveFormsModule],
|
|
100
|
-
},
|
|
101
|
-
props: {
|
|
102
|
-
...args,
|
|
103
|
-
form: new FormGroup({
|
|
104
|
-
date: new FormControl<Date | null>(null),
|
|
105
|
-
}),
|
|
106
|
-
},
|
|
107
|
-
template: `
|
|
108
|
-
<div class="flex min-h-80 justify-end p-6">
|
|
109
|
-
<form [formGroup]="form">
|
|
110
|
-
<ads-datepicker-selector
|
|
111
|
-
formControlName="date"
|
|
112
|
-
[buttonVariant]="buttonVariant"
|
|
113
|
-
[buttonColor]="buttonColor"
|
|
114
|
-
[buttonOnlyIconButton]="buttonOnlyIconButton"
|
|
115
|
-
[buttonIcon]="buttonIcon"
|
|
116
|
-
[buttonLabelMode]="buttonLabelMode"
|
|
117
|
-
[isPickerDisabled]="isPickerDisabled"
|
|
118
|
-
></ads-datepicker-selector>
|
|
119
|
-
</form>
|
|
120
|
-
</div>
|
|
121
|
-
`,
|
|
122
|
-
}),
|
|
123
|
-
};
|