ngx-opalbytes-components 1.25.1 → 1.27.0
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/README.md +497 -0
- package/fesm2022/ngx-opalbytes-components.mjs +890 -2
- package/fesm2022/ngx-opalbytes-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/shared/components/checkbox/checkbox.component.css +131 -0
- package/src/lib/shared/components/checkbox/checkbox.component.html +84 -0
- package/src/lib/shared/components/checkbox/checkbox.component.spec.ts +344 -0
- package/src/lib/shared/components/checkbox/checkbox.component.ts +258 -0
- package/src/lib/shared/components/checkbox/checkbox.stories.ts +240 -0
- package/src/lib/shared/components/index.ts +4 -0
- package/src/lib/shared/components/radio/radio-button.component.css +95 -0
- package/src/lib/shared/components/radio/radio-button.component.html +32 -0
- package/src/lib/shared/components/radio/radio-button.component.ts +133 -0
- package/src/lib/shared/components/radio/radio-button.stories.ts +94 -0
- package/src/lib/shared/components/radio/radio-group.component.css +21 -0
- package/src/lib/shared/components/radio/radio-group.component.ts +216 -0
- package/src/lib/shared/components/radio/radio.component.spec.ts +128 -0
- package/src/lib/shared/components/radio/radio.stories.ts +128 -0
- package/src/lib/shared/components/slide-toggle/slide-toggle.component.css +135 -0
- package/src/lib/shared/components/slide-toggle/slide-toggle.component.html +48 -0
- package/src/lib/shared/components/slide-toggle/slide-toggle.component.spec.ts +155 -0
- package/src/lib/shared/components/slide-toggle/slide-toggle.component.ts +233 -0
- package/src/lib/shared/components/slide-toggle/slide-toggle.stories.ts +165 -0
- package/types/ngx-opalbytes-components.d.ts +228 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
ChangeDetectorRef,
|
|
5
|
+
Component,
|
|
6
|
+
EventEmitter,
|
|
7
|
+
forwardRef,
|
|
8
|
+
HostBinding,
|
|
9
|
+
inject,
|
|
10
|
+
Input,
|
|
11
|
+
OnChanges,
|
|
12
|
+
OnDestroy,
|
|
13
|
+
Output,
|
|
14
|
+
SimpleChanges,
|
|
15
|
+
} from "@angular/core";
|
|
16
|
+
import { AbstractControl, ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
17
|
+
|
|
18
|
+
import { LucideDynamicIcon } from "@lucide/angular";
|
|
19
|
+
import { Subscription } from "rxjs";
|
|
20
|
+
|
|
21
|
+
let nextCheckboxId = 0;
|
|
22
|
+
|
|
23
|
+
export interface ICaoCheckboxChangeEvent {
|
|
24
|
+
checked: boolean;
|
|
25
|
+
source: CaoCheckboxComponent;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Component({
|
|
29
|
+
selector: "cao-checkbox",
|
|
30
|
+
standalone: true,
|
|
31
|
+
imports: [CommonModule, LucideDynamicIcon],
|
|
32
|
+
templateUrl: "./checkbox.component.html",
|
|
33
|
+
styleUrl: "./checkbox.component.css",
|
|
34
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
35
|
+
providers: [
|
|
36
|
+
{
|
|
37
|
+
provide: NG_VALUE_ACCESSOR,
|
|
38
|
+
useExisting: forwardRef(() => CaoCheckboxComponent),
|
|
39
|
+
multi: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
export class CaoCheckboxComponent implements ControlValueAccessor, OnChanges, OnDestroy {
|
|
44
|
+
@Input() checked = false;
|
|
45
|
+
@Input() indeterminate = false;
|
|
46
|
+
@Input() isDisabled = false;
|
|
47
|
+
@Input() required = false;
|
|
48
|
+
@Input() label = "";
|
|
49
|
+
@Input() labelPosition: "before" | "after" = "after";
|
|
50
|
+
@Input() name = "";
|
|
51
|
+
@Input() id = "";
|
|
52
|
+
@Input() ariaLabel = "";
|
|
53
|
+
@Input() ariaLabelledBy = "";
|
|
54
|
+
@Input() dataCy = "";
|
|
55
|
+
@Input() control?: AbstractControl | null;
|
|
56
|
+
@Input() errorMessage = "";
|
|
57
|
+
|
|
58
|
+
@Input() color?: string;
|
|
59
|
+
@Input() uncheckedColor?: string;
|
|
60
|
+
@Input() disabledColor?: string;
|
|
61
|
+
@Input() labelColor?: string;
|
|
62
|
+
@Input() disabledLabelColor?: string;
|
|
63
|
+
@Input() focusRingColor?: string;
|
|
64
|
+
|
|
65
|
+
@Input() size?: string;
|
|
66
|
+
@Input() borderRadius?: string;
|
|
67
|
+
@Input() animationDuration?: string;
|
|
68
|
+
|
|
69
|
+
@Input() checkedIcon = "";
|
|
70
|
+
@Input() uncheckedIcon = "";
|
|
71
|
+
@Input() indeterminateIcon = "";
|
|
72
|
+
@Input() isLucideIcon = false;
|
|
73
|
+
@Input() iconColor = "";
|
|
74
|
+
@Input() checkedIconColor = "";
|
|
75
|
+
@Input() uncheckedIconColor = "";
|
|
76
|
+
@Input() iconSize: string | number = 14;
|
|
77
|
+
@Input() iconStrokeWidth: string | number = 2.5;
|
|
78
|
+
|
|
79
|
+
@Input() set disabled(value: boolean) {
|
|
80
|
+
this.isDisabled = value;
|
|
81
|
+
this.cdr.markForCheck();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get disabled(): boolean {
|
|
85
|
+
return this.isDisabled;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Output() readonly checkedChange = new EventEmitter<boolean>();
|
|
89
|
+
@Output() readonly indeterminateChange = new EventEmitter<boolean>();
|
|
90
|
+
@Output() readonly checkboxChange = new EventEmitter<ICaoCheckboxChangeEvent>();
|
|
91
|
+
|
|
92
|
+
private readonly cdr = inject(ChangeDetectorRef);
|
|
93
|
+
private readonly uid = `cao-checkbox-${nextCheckboxId++}`;
|
|
94
|
+
private controlSub?: Subscription;
|
|
95
|
+
private onChange: (value: boolean) => void = () => {};
|
|
96
|
+
private onTouched: () => void = () => {};
|
|
97
|
+
|
|
98
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
99
|
+
if (changes["control"]) {
|
|
100
|
+
this.controlSub?.unsubscribe();
|
|
101
|
+
this.controlSub = this.control?.statusChanges.subscribe(() =>
|
|
102
|
+
this.cdr.markForCheck(),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
ngOnDestroy(): void {
|
|
108
|
+
this.controlSub?.unsubscribe();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
get inputId(): string {
|
|
112
|
+
return this.id || this.uid;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get hasError(): boolean {
|
|
116
|
+
return !!this.errorMessage;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get hasInvalidState(): boolean {
|
|
120
|
+
return !!(this.control?.touched && this.control?.invalid);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get hasValidState(): boolean {
|
|
124
|
+
return !!(this.control?.touched && this.control?.valid);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get resolvedIconColor(): string {
|
|
128
|
+
if (this.indeterminate) {
|
|
129
|
+
return this.iconColor || this.checkedIconColor;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return this.checked
|
|
133
|
+
? this.checkedIconColor || this.iconColor
|
|
134
|
+
: this.uncheckedIconColor || this.iconColor;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@HostBinding("style")
|
|
138
|
+
get hostStyles(): Record<string, string> {
|
|
139
|
+
const styles: Record<string, string> = {};
|
|
140
|
+
|
|
141
|
+
if (this.color) {
|
|
142
|
+
styles["--cao-checkbox-color"] = this.color;
|
|
143
|
+
}
|
|
144
|
+
if (this.uncheckedColor) {
|
|
145
|
+
styles["--cao-checkbox-unselected"] = this.uncheckedColor;
|
|
146
|
+
}
|
|
147
|
+
if (this.disabledColor) {
|
|
148
|
+
styles["--cao-checkbox-disabled"] = this.disabledColor;
|
|
149
|
+
}
|
|
150
|
+
if (this.labelColor) {
|
|
151
|
+
styles["--cao-checkbox-label"] = this.labelColor;
|
|
152
|
+
}
|
|
153
|
+
if (this.disabledLabelColor) {
|
|
154
|
+
styles["--cao-checkbox-label-disabled"] = this.disabledLabelColor;
|
|
155
|
+
}
|
|
156
|
+
if (this.focusRingColor) {
|
|
157
|
+
styles["--cao-checkbox-focus-ring"] = this.focusRingColor;
|
|
158
|
+
}
|
|
159
|
+
if (this.size) {
|
|
160
|
+
styles["--cao-checkbox-size"] = this.size;
|
|
161
|
+
}
|
|
162
|
+
if (this.borderRadius) {
|
|
163
|
+
styles["--cao-checkbox-radius"] = this.borderRadius;
|
|
164
|
+
}
|
|
165
|
+
if (this.animationDuration) {
|
|
166
|
+
styles["--cao-checkbox-duration"] = this.animationDuration;
|
|
167
|
+
}
|
|
168
|
+
if (this.resolvedIconColor) {
|
|
169
|
+
styles["--cao-checkbox-icon-color"] = this.resolvedIconColor;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
styles["--cao-checkbox-icon-size"] = this.toCssLength(this.iconSize);
|
|
173
|
+
|
|
174
|
+
return styles;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
toggle(): void {
|
|
178
|
+
if (this.isDisabled) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.setChecked(!this.checked, true);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
setChecked(value: boolean, emit = true): void {
|
|
186
|
+
if (this.isDisabled) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const wasIndeterminate = this.indeterminate;
|
|
191
|
+
|
|
192
|
+
this.checked = value;
|
|
193
|
+
this.indeterminate = false;
|
|
194
|
+
this.onChange(value);
|
|
195
|
+
|
|
196
|
+
if (emit) {
|
|
197
|
+
this.checkedChange.emit(value);
|
|
198
|
+
this.checkboxChange.emit({ checked: value, source: this });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (wasIndeterminate) {
|
|
202
|
+
this.indeterminateChange.emit(false);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.cdr.markForCheck();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
setIndeterminate(value: boolean): void {
|
|
209
|
+
if (this.isDisabled || this.indeterminate === value) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.indeterminate = value;
|
|
214
|
+
this.indeterminateChange.emit(value);
|
|
215
|
+
this.cdr.markForCheck();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
enable(): void {
|
|
219
|
+
this.isDisabled = false;
|
|
220
|
+
this.cdr.markForCheck();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
disable(): void {
|
|
224
|
+
this.isDisabled = true;
|
|
225
|
+
this.cdr.markForCheck();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
onInputChange(event: Event): void {
|
|
229
|
+
const target = event.target as HTMLInputElement;
|
|
230
|
+
this.setChecked(target.checked, true);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
onBlur(): void {
|
|
234
|
+
this.onTouched();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
writeValue(value: boolean | null): void {
|
|
238
|
+
this.checked = !!value;
|
|
239
|
+
this.cdr.markForCheck();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
registerOnChange(fn: (value: boolean) => void): void {
|
|
243
|
+
this.onChange = fn;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
registerOnTouched(fn: () => void): void {
|
|
247
|
+
this.onTouched = fn;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
setDisabledState(isDisabled: boolean): void {
|
|
251
|
+
this.isDisabled = isDisabled;
|
|
252
|
+
this.cdr.markForCheck();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private toCssLength(value: string | number): string {
|
|
256
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { FormsModule } from '@angular/forms';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
LucideCheck,
|
|
5
|
+
LucideCircle,
|
|
6
|
+
LucideHeart,
|
|
7
|
+
LucideMinus,
|
|
8
|
+
LucideX,
|
|
9
|
+
provideLucideIcons,
|
|
10
|
+
} from '@lucide/angular';
|
|
11
|
+
import { applicationConfig, type Meta, type StoryObj } from '@storybook/angular-vite';
|
|
12
|
+
import { fn } from 'storybook/test';
|
|
13
|
+
|
|
14
|
+
import { CaoCheckboxComponent } from './checkbox.component';
|
|
15
|
+
|
|
16
|
+
const imageIcon =
|
|
17
|
+
'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Ccircle cx="12" cy="12" r="8" fill="%234f46e5"/%3E%3C/svg%3E';
|
|
18
|
+
|
|
19
|
+
const meta: Meta<CaoCheckboxComponent> = {
|
|
20
|
+
title: 'Componentes/Checkbox',
|
|
21
|
+
component: CaoCheckboxComponent,
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
decorators: [
|
|
24
|
+
applicationConfig({
|
|
25
|
+
providers: [
|
|
26
|
+
provideLucideIcons(
|
|
27
|
+
LucideCheck,
|
|
28
|
+
LucideMinus,
|
|
29
|
+
LucideX,
|
|
30
|
+
LucideCircle,
|
|
31
|
+
LucideHeart,
|
|
32
|
+
),
|
|
33
|
+
],
|
|
34
|
+
}),
|
|
35
|
+
(story) => ({
|
|
36
|
+
...story,
|
|
37
|
+
moduleMetadata: {
|
|
38
|
+
imports: [FormsModule],
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
argTypes: {
|
|
43
|
+
checked: { control: 'boolean' },
|
|
44
|
+
indeterminate: { control: 'boolean' },
|
|
45
|
+
isDisabled: { control: 'boolean' },
|
|
46
|
+
disabled: { control: 'boolean' },
|
|
47
|
+
required: { control: 'boolean' },
|
|
48
|
+
label: { control: 'text' },
|
|
49
|
+
labelPosition: { control: 'select', options: ['before', 'after'] },
|
|
50
|
+
name: { control: 'text' },
|
|
51
|
+
id: { control: 'text' },
|
|
52
|
+
ariaLabel: { control: 'text' },
|
|
53
|
+
ariaLabelledBy: { control: 'text' },
|
|
54
|
+
dataCy: { control: 'text' },
|
|
55
|
+
color: { control: 'color' },
|
|
56
|
+
uncheckedColor: { control: 'color' },
|
|
57
|
+
disabledColor: { control: 'color' },
|
|
58
|
+
labelColor: { control: 'color' },
|
|
59
|
+
disabledLabelColor: { control: 'color' },
|
|
60
|
+
focusRingColor: { control: 'color' },
|
|
61
|
+
size: { control: 'text' },
|
|
62
|
+
borderRadius: { control: 'text' },
|
|
63
|
+
animationDuration: { control: 'text' },
|
|
64
|
+
checkedIcon: { control: 'text' },
|
|
65
|
+
uncheckedIcon: { control: 'text' },
|
|
66
|
+
indeterminateIcon: { control: 'text' },
|
|
67
|
+
isLucideIcon: { control: 'boolean' },
|
|
68
|
+
iconColor: { control: 'color' },
|
|
69
|
+
checkedIconColor: { control: 'color' },
|
|
70
|
+
uncheckedIconColor: { control: 'color' },
|
|
71
|
+
iconSize: { control: 'text' },
|
|
72
|
+
iconStrokeWidth: { control: 'text' },
|
|
73
|
+
},
|
|
74
|
+
args: {
|
|
75
|
+
checked: false,
|
|
76
|
+
indeterminate: false,
|
|
77
|
+
isDisabled: false,
|
|
78
|
+
required: false,
|
|
79
|
+
label: 'Aceito os termos',
|
|
80
|
+
labelPosition: 'after',
|
|
81
|
+
checkedIcon: '',
|
|
82
|
+
uncheckedIcon: '',
|
|
83
|
+
indeterminateIcon: '',
|
|
84
|
+
isLucideIcon: false,
|
|
85
|
+
iconColor: '',
|
|
86
|
+
checkedIconColor: '',
|
|
87
|
+
uncheckedIconColor: '',
|
|
88
|
+
iconSize: 14,
|
|
89
|
+
iconStrokeWidth: 2.5,
|
|
90
|
+
checkedChange: fn(),
|
|
91
|
+
indeterminateChange: fn(),
|
|
92
|
+
checkboxChange: fn(),
|
|
93
|
+
},
|
|
94
|
+
render: (args) => ({
|
|
95
|
+
props: args,
|
|
96
|
+
template: `
|
|
97
|
+
<cao-checkbox
|
|
98
|
+
[(ngModel)]="checked"
|
|
99
|
+
[indeterminate]="indeterminate"
|
|
100
|
+
[isDisabled]="isDisabled"
|
|
101
|
+
[required]="required"
|
|
102
|
+
[label]="label"
|
|
103
|
+
[labelPosition]="labelPosition"
|
|
104
|
+
[name]="name"
|
|
105
|
+
[id]="id"
|
|
106
|
+
[ariaLabel]="ariaLabel"
|
|
107
|
+
[ariaLabelledBy]="ariaLabelledBy"
|
|
108
|
+
[dataCy]="dataCy"
|
|
109
|
+
[color]="color"
|
|
110
|
+
[uncheckedColor]="uncheckedColor"
|
|
111
|
+
[disabledColor]="disabledColor"
|
|
112
|
+
[labelColor]="labelColor"
|
|
113
|
+
[disabledLabelColor]="disabledLabelColor"
|
|
114
|
+
[focusRingColor]="focusRingColor"
|
|
115
|
+
[size]="size"
|
|
116
|
+
[borderRadius]="borderRadius"
|
|
117
|
+
[animationDuration]="animationDuration"
|
|
118
|
+
[checkedIcon]="checkedIcon"
|
|
119
|
+
[uncheckedIcon]="uncheckedIcon"
|
|
120
|
+
[indeterminateIcon]="indeterminateIcon"
|
|
121
|
+
[isLucideIcon]="isLucideIcon"
|
|
122
|
+
[iconColor]="iconColor"
|
|
123
|
+
[checkedIconColor]="checkedIconColor"
|
|
124
|
+
[uncheckedIconColor]="uncheckedIconColor"
|
|
125
|
+
[iconSize]="iconSize"
|
|
126
|
+
[iconStrokeWidth]="iconStrokeWidth"
|
|
127
|
+
(checkedChange)="checkedChange($event)"
|
|
128
|
+
(indeterminateChange)="indeterminateChange($event)"
|
|
129
|
+
(checkboxChange)="checkboxChange($event)">
|
|
130
|
+
</cao-checkbox>
|
|
131
|
+
`,
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default meta;
|
|
136
|
+
type Story = StoryObj<CaoCheckboxComponent>;
|
|
137
|
+
|
|
138
|
+
export const Padrao: Story = {};
|
|
139
|
+
|
|
140
|
+
export const Marcado: Story = {
|
|
141
|
+
args: {
|
|
142
|
+
checked: true,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const Indeterminado: Story = {
|
|
147
|
+
args: {
|
|
148
|
+
indeterminate: true,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const Desabilitado: Story = {
|
|
153
|
+
args: {
|
|
154
|
+
isDisabled: true,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const DesabilitadoMarcado: Story = {
|
|
159
|
+
args: {
|
|
160
|
+
checked: true,
|
|
161
|
+
isDisabled: true,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const LabelAntes: Story = {
|
|
166
|
+
args: {
|
|
167
|
+
checked: true,
|
|
168
|
+
labelPosition: 'before',
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const Obrigatorio: Story = {
|
|
173
|
+
args: {
|
|
174
|
+
required: true,
|
|
175
|
+
label: 'Campo obrigatório',
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const CoresCustomizadas: Story = {
|
|
180
|
+
args: {
|
|
181
|
+
checked: true,
|
|
182
|
+
label: 'Cores customizadas',
|
|
183
|
+
color: '#16a34a',
|
|
184
|
+
uncheckedColor: '#94a3b8',
|
|
185
|
+
labelColor: '#166534',
|
|
186
|
+
focusRingColor: 'rgba(22, 163, 74, 0.35)',
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const TamanhoCustomizado: Story = {
|
|
191
|
+
args: {
|
|
192
|
+
checked: true,
|
|
193
|
+
label: 'Tamanho customizado',
|
|
194
|
+
size: '28px',
|
|
195
|
+
borderRadius: '8px',
|
|
196
|
+
animationDuration: '300ms',
|
|
197
|
+
iconSize: 20,
|
|
198
|
+
iconStrokeWidth: 3,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const IconesLucide: Story = {
|
|
203
|
+
args: {
|
|
204
|
+
checked: true,
|
|
205
|
+
label: 'Ícones Lucide',
|
|
206
|
+
checkedIcon: 'check',
|
|
207
|
+
uncheckedIcon: 'x',
|
|
208
|
+
indeterminateIcon: 'minus',
|
|
209
|
+
isLucideIcon: true,
|
|
210
|
+
checkedIconColor: '#ffffff',
|
|
211
|
+
uncheckedIconColor: '#6b7280',
|
|
212
|
+
iconSize: 14,
|
|
213
|
+
iconStrokeWidth: 2.5,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export const IconesCustomizados: Story = {
|
|
218
|
+
args: {
|
|
219
|
+
checked: true,
|
|
220
|
+
label: 'Ícones customizados',
|
|
221
|
+
checkedIcon: 'heart',
|
|
222
|
+
uncheckedIcon: 'circle',
|
|
223
|
+
isLucideIcon: true,
|
|
224
|
+
checkedIconColor: '#ffffff',
|
|
225
|
+
uncheckedIconColor: '#db2777',
|
|
226
|
+
color: '#db2777',
|
|
227
|
+
uncheckedColor: '#f9a8d4',
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export const IconeImagem: Story = {
|
|
232
|
+
args: {
|
|
233
|
+
checked: true,
|
|
234
|
+
label: 'Ícone via URL/data URI',
|
|
235
|
+
checkedIcon: imageIcon,
|
|
236
|
+
uncheckedIcon: imageIcon,
|
|
237
|
+
isLucideIcon: false,
|
|
238
|
+
iconSize: 12,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
@@ -27,4 +27,8 @@ export * from "./error/error"
|
|
|
27
27
|
|
|
28
28
|
export * from "./card/card.component"
|
|
29
29
|
export * from "./base-toggle/base-toggle.component"
|
|
30
|
+
export * from "./slide-toggle/slide-toggle.component"
|
|
31
|
+
export * from "./radio/radio-group.component"
|
|
32
|
+
export * from "./radio/radio-button.component"
|
|
33
|
+
export * from "./checkbox/checkbox.component"
|
|
30
34
|
export * from "./footer/footer"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.cao-radio {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 8px;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.cao-radio--disabled {
|
|
14
|
+
cursor: not-allowed;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cao-radio__input {
|
|
18
|
+
position: absolute;
|
|
19
|
+
width: 1px;
|
|
20
|
+
height: 1px;
|
|
21
|
+
margin: -1px;
|
|
22
|
+
padding: 0;
|
|
23
|
+
border: 0;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
clip: rect(0 0 0 0);
|
|
26
|
+
clip-path: inset(50%);
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.cao-radio__control {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
flex: none;
|
|
35
|
+
width: var(--cao-radio-size, 20px);
|
|
36
|
+
height: var(--cao-radio-size, 20px);
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
border: 2px solid var(--cao-radio-unselected, #6b7280);
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
transition: border-color var(--cao-radio-duration, 200ms) ease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.cao-radio__dot {
|
|
44
|
+
width: 50%;
|
|
45
|
+
height: 50%;
|
|
46
|
+
border-radius: 50%;
|
|
47
|
+
background-color: var(--cao-radio-color, #4f46e5);
|
|
48
|
+
transform: scale(0);
|
|
49
|
+
transition:
|
|
50
|
+
transform var(--cao-radio-duration, 200ms) ease,
|
|
51
|
+
background-color var(--cao-radio-duration, 200ms) ease;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.cao-radio__label {
|
|
55
|
+
color: var(--cao-radio-label, #111827);
|
|
56
|
+
font-size: 0.875rem;
|
|
57
|
+
line-height: 1.25rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.cao-radio__label:empty {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cao-radio:not(.cao-radio--disabled):hover .cao-radio__control,
|
|
65
|
+
.cao-radio--checked .cao-radio__control {
|
|
66
|
+
border-color: var(--cao-radio-color, #4f46e5);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cao-radio--checked .cao-radio__dot {
|
|
70
|
+
transform: scale(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.cao-radio--disabled .cao-radio__control {
|
|
74
|
+
border-color: var(--cao-radio-disabled, #d1d5db);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cao-radio--disabled .cao-radio__dot {
|
|
78
|
+
background-color: var(--cao-radio-disabled, #d1d5db);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cao-radio--disabled .cao-radio__label {
|
|
82
|
+
color: var(--cao-radio-label-disabled, #9ca3af);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.cao-radio__input:focus-visible + .cao-radio__control {
|
|
86
|
+
box-shadow: 0 0 0 3px var(--cao-radio-focus-ring, rgba(79, 70, 229, 0.35));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cao-radio--label-before .cao-radio__control {
|
|
90
|
+
order: 2;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.cao-radio--label-before .cao-radio__label {
|
|
94
|
+
order: 1;
|
|
95
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<label
|
|
2
|
+
class="cao-radio"
|
|
3
|
+
[class.cao-radio--checked]="isSelected"
|
|
4
|
+
[class.cao-radio--disabled]="effectiveDisabled"
|
|
5
|
+
[class.cao-radio--label-before]="effectiveLabelPosition === 'before'">
|
|
6
|
+
<input
|
|
7
|
+
#input
|
|
8
|
+
class="cao-radio__input"
|
|
9
|
+
type="radio"
|
|
10
|
+
[checked]="isSelected"
|
|
11
|
+
[disabled]="effectiveDisabled"
|
|
12
|
+
[required]="isRequired"
|
|
13
|
+
[attr.name]="effectiveName"
|
|
14
|
+
[attr.id]="inputId"
|
|
15
|
+
[attr.aria-label]="ariaLabel || null"
|
|
16
|
+
[attr.aria-labelledby]="ariaLabelledBy || null"
|
|
17
|
+
[attr.data-cy]="dataCy || null"
|
|
18
|
+
(change)="select()"
|
|
19
|
+
(blur)="onBlur()" />
|
|
20
|
+
|
|
21
|
+
<span class="cao-radio__control" aria-hidden="true">
|
|
22
|
+
<span class="cao-radio__dot"></span>
|
|
23
|
+
</span>
|
|
24
|
+
|
|
25
|
+
<span class="cao-radio__label">
|
|
26
|
+
@if (label) {
|
|
27
|
+
{{ label }}
|
|
28
|
+
} @else {
|
|
29
|
+
<ng-content />
|
|
30
|
+
}
|
|
31
|
+
</span>
|
|
32
|
+
</label>
|